<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>测试</title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <link href="css/index.css" type="text/css" rel="stylesheet"/>
        <script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
    </head>
    <body>
        <table class="table-s1 center">
            <caption>
                与大小姐+3相似的推荐卡牌
            </caption>
            <thead>
                <tr>
                    <th width="5%" scope="col">对比</th>
                    <th width="10%" scope="col">小图</th>
                    <th width="15%" scope="col">名字</th>
                    <th width="8%" scope="col" class="colSort"><a sort="starLevel">星级</a></th>
                    <th width="7%" scope="col">职业</th>
                    <th width="10%" scope="col" class="colSort"><a sort="hpMax">最大生命</a></th>
                    <th width="10%" scope="col" class="colSort"><a sort="attackMax">最大攻击</a></th>
                    <th width="10%" scope="col">主动技能</th>
                    <th width="10%" scope="col">被动技能</th>
                    <th width="15%" scope="col">获得来源</th>
                </tr>
            </thead>
            <tbody>
                <tr class="cardList">
                    <td>
                        <input class="compareCarCheckbox" data-id="3357" title="勾选，以加入至卡牌对比车中。" type="checkbox"/> 
                    </td>
                    <td>
                        <a href="http://db.duowan.com/mt/card/detail/3357.html"><img src="http://s1.dwstatic.com/diydb/34/72/3472d387ddd472692f0c3dd244b21cc34980.png" class="img-rounded" style="width:70px"></a>
                    </td>
                    <td>
                        <a target="_blank" class="cardColorpurple" href="http://db.duowan.com/mt/card/detail/3357.html">国足光光+3</a>
                    </td>
                    <td>
                        <a title="查看所有星级为“5星金龙”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[starLevel]=5.5">5星金龙</a>
                    </td>
                    <td>
                        <a title="查看所有职业为“圣骑士”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[profession]=5Zyj6aqR5aOr">圣骑士</a>
                    </td>
                    <td>
                        41924
                    </td>
                    <td>
                        6953
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[initiativeSkill]=6auY57qn5Zyj5YWJ5pyv">高级圣光术</a>
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[passiveSkill]=6auY57qn56We5Zyj5aSp6LWL&amp;tipsCardNo=3357">高级神圣天赋</a>
                    </td>
                    <td>
                        <a title="查看所有来源为“英雄进化”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=6Iux6ZuE6L_1_b5YyW">英雄进化</a><br/>
                        <a title="查看所有来源为“主角卡”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=5Li76KeS5Y2h">主角卡</a><br/>
                    </td>
                </tr>
                <tr class="even cardList">
                    <td>
                        <input class="compareCarCheckbox" data-id="3359" title="勾选，以加入至卡牌对比车中。" type="checkbox">
                    </td>
                    <td>
                        <a href="http://db.duowan.com/mt/card/detail/3359.html"><img src="http://s1.dwstatic.com/diydb/73/E1/73e1eab8d55a33558ac7eb63dc662aeb2952.png" class="img-rounded" style="width:70px"></a>
                    </td>
                    <td>
                        <a target="_blank" class="cardColorpurple" href="http://db.duowan.com/mt/card/detail/3359.html">国足棍棍+3</a>
                    </td>
                    <td>
                        <a title="查看所有星级为“5星金龙”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[starLevel]=5.5">5星金龙</a>
                    </td>
                    <td>
                        <a title="查看所有职业为“圣骑士”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[profession]=5Zyj6aqR5aOr">圣骑士</a>
                    </td>
                    <td>
                        42602
                    </td>
                    <td>
                        7064
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[initiativeSkill]=6auY57qn5Zyj5YWJ5pyv">高级圣光术</a>
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[passiveSkill]=6auY57qn56We5Zyj5aSp6LWL&amp;tipsCardNo=3359">高级神圣天赋</a>
                    </td>
                    <td>
                        <a title="查看所有来源为“英雄进化”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=6Iux6ZuE6L_1_b5YyW">英雄进化</a><br/>
                        <a title="查看所有来源为“主角卡”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=5Li76KeS5Y2h">主角卡</a><br/>
                    </td>
                </tr>
                <tr class="cardList">
                    <td>
                        <input class="compareCarCheckbox" data-id="3361" title="勾选，以加入至卡牌对比车中。" type="checkbox">
                    </td>
                    <td>
                        <a href="http://db.duowan.com/mt/card/detail/3361.html"><img src="http://s1.dwstatic.com/diydb/44/D5/44d5872a63076744d41b2abbf825c5994892.png" class="img-rounded" style="width:70px"></a>
                    </td>
                    <td>
                        <a target="_blank" class="cardColorpurple" href="http://db.duowan.com/mt/card/detail/3361.html">国足骑骑+3</a>
                    </td>
                    <td>
                        <a title="查看所有星级为“5星金龙”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[starLevel]=5.5">5星金龙</a>
                    </td>
                    <td>
                        <a title="查看所有职业为“圣骑士”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[profession]=5Zyj6aqR5aOr">圣骑士</a>
                    </td>
                    <td>
                        41924
                    </td>
                    <td>
                        6953
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[initiativeSkill]=6auY57qn5Zyj5YWJ5pyv">高级圣光术</a>
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[passiveSkill]=6auY57qn56We5Zyj5aSp6LWL&amp;tipsCardNo=3361">高级神圣天赋</a>
                    </td>
                    <td>
                        <a title="查看所有来源为“英雄进化”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=6Iux6ZuE6L_1_b5YyW">英雄进化</a><br/>
                        <a title="查看所有来源为“主角卡”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=5Li76KeS5Y2h">主角卡</a><br/>
                    </td>
                </tr>
                <tr class="even cardList">
                    <td>
                        <input class="compareCarCheckbox" data-id="3355" title="勾选，以加入至卡牌对比车中。" type="checkbox">
                    </td>
                    <td>
                        <a href="http://db.duowan.com/mt/card/detail/3355.html"><img src="http://s1.dwstatic.com/diydb/10/B7/10b712a3b130b6f46f028540d5448e48678.png" class="img-rounded" style="width:70px"></a>
                    </td>
                    <td>
                        <a target="_blank" class="cardColorpurple" href="http://db.duowan.com/mt/card/detail/3355.html">国足圣圣+3</a>
                    </td>
                    <td>
                        <a title="查看所有星级为“5星金龙”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[starLevel]=5.5">5星金龙</a>
                    </td>
                    <td>
                        <a title="查看所有职业为“圣骑士”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[profession]=5Zyj6aqR5aOr">圣骑士</a>
                    </td>
                    <td>
                        41924
                    </td>
                    <td>
                        6953
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[initiativeSkill]=6auY57qn5Zyj5YWJ5pyv">高级圣光术</a>
                    </td>
                    <td>
                        <a class="tooltipLink" href="http://db.duowan.com/mt/card/list.html?conditions[passiveSkill]=6auY57qn56We5Zyj5aSp6LWL&amp;tipsCardNo=3355">高级神圣天赋</a>
                    </td>
                    <td>
                        <a title="查看所有来源为“英雄进化”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=6Iux6ZuE6L_1_b5YyW">英雄进化</a><br/>
                        <a title="查看所有来源为“主角卡”的卡牌" href="http://db.duowan.com/mt/card/list.html?conditions[gainFrom]=5Li76KeS5Y2h">主角卡</a><br/>
                    </td>
                </tr>
            </tbody>
        </table>
        <script type="text/javascript">
            (function() {
                var Car = function() {
                    var _self = this;
                    this.list = [];
                    this.add = function(id) {
                        _self.list.push(id);
                    };
                    this.delete = function(id) {
                        for (var i = 0; i < _self.list.length; i++) {
                            if (id == _self.list[i]) {
                                _self.list.splice(i, 1);
                                break;
                            }
                        }
                    };
                };
                var car = new Car();
                $(".compareCarCheckbox").click(function() {
                    var $this = $(this);
                    if ($this.prop('checked')) {
                        car.add($this.data("id"));
                        var $compareBtn = $("<div></div>").attr({"class": "compareBtnLink"});
                        $compareBtn.html("<a href='#'>对比</a>");
                        $this.after($compareBtn);
                    } else {
                        car.delete($this.data("id"));
                        $this.next(".compareBtnLink").remove();
                    }
                });
                $('.cardList').on('click', '.compareBtnLink a', function() {
                    var url = "http://db.duowan.com/mt/card/compare.html?ids=";
                    var idstr = "";
                    for (var i = 0; i < car.list.length; i++) {
                        idstr += car.list[i] + "-";
                    }
                    var ids = idstr.substr(0, idstr.length - 1);
                    var href = url + ids;
                    console.log(href);
                    return false;
                });
            })();
        </script>
    </body>
</html>